<template>
  <div>
    <h1>app</h1>
    <button @click="getStu_info">get不加参数</button>
    <button @click="getEntry_exam">get有参数 params</button>
    <button @click="getStu_item">get有参数 query</button><br />

    学号：<input type="text" v-model="stu_id" /><br />
    姓名：<input type="text" v-model="stu_name" /><br />
    语文：<input type="text" v-model="chinese" /><br />
    数学：<input type="text" v-model="math" /><br />
    英语：<input type="text" v-model="english" /><br />
    理综：<input type="text" v-model="lizong" /><br />
    文综：<input type="text" v-model="wenzong" /><br />
    <button @click="submit">提交数据post请求</button>
    <button @click="postNoArgument">post请求不传参</button>
  </div>
</template>

<script>
import request from "./api/request";
  export default {
    data(){
      return{
        stu_id: "",
        stu_name: "",
        chinese: 0,
        math: 0,
        english: 0,
        lizong: 0,
        wenzong: 0,
      };
    },
    // mounted(){
    //   console.log(instance);
    //   instance({
    //     method:"get",
    //     url:"/search_info_not",
    //     transformRequest:[
    //       (data)=>{
    //         console.log(data);
    //         return data;
    //       },
    //     ],
    //     transformResponse:[
    //       (res)=>{
    //         console.log(res);
    //         return res;
    //       },
    //     ],
    //     data:{
    //       zheshu:"软乎乎的肚子",
    //     },
    //   }).then((res)=>{
    //     console.log(res);
    //   }).catch((err)=>{
    //     console.log(err);
    //   });
    // }
    methods:{
      async getStu_info(){
        let result = await request("get","/search_info_not",{},"");
        console.log(result);
      },
      async getEntry_exam(){
        let result = await request("get","/search_entry/02",{},"");
        console.log(result);
      },
      async getStu_item(){
        let result = await request("get","/search_info_item",{stu_id:"001"},"");
        console.log(result);
      },
      async submit(){
        let params = {
          stu_id:this.stu_id,
          stu_name:this.stu_name,
          chinese:this.chinese,
          math:this.math,
          english:this.english,
          lizong:this.lizong,
          wenzong:this.wenzong,
        };
        let result = await request("post","/entry_exam",params,"form");
        console.log(result);
      },
      async postNoArgument(){
        //        缺少路径 需要补一个  /studyAxiosPost
        let result = await request("post","/studyAxiosPost",{},"");
        console.log(result);
      }
    }
  }
</script>

<style lang="scss" scoped>

</style>